

layui.use(['layer', 'form', 'admin', 'laydate', 'ax','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    // 让当前iframe弹层高度适应
    admin.iframeAuto();

    var ajax = new $ax(Feng.ctxPath + "/region/getRegionInfo?regionId=" + Feng.getUrlParam("regionId"));
    var result = ajax.start();

    //查询上级
    var pAjax = new $ax(Feng.ctxPath + "/region/selectParent", function (data) {
        $("#parentId").append(data)
    })
    pAjax.set("regionLevel",result.data.regionLevel)
    pAjax.start();
    form.render('select');
    $("input[name='regionLevel']").each(function () {
        if($(this).val()==result.data.regionLevel){
            $(this).attr("checked", "checked");
            return false;
        }
    })
    form.val('regionForm', result.data);

    // 添加表单验证方法
    form.verify({
        sort: [/^[\d]{1,3}$/, '排序号为1-3位正整数']
    });

    // 表单提交事件
    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/region/edit", function (data) {
        Feng.success("修改成功！");

        //传给上个页面，刷新table用
        admin.putTempData('formOk', true);

        //关掉对话框
        admin.closeThisDialog();
        }, function (data) {
            Feng.error("修改成功！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });
});